import React, {  useEffect } from "react";
import { queryVersionDistribution } from "@/apis/charts";
import { useDispatch } from "react-redux";
import { setVerisionDistData } from "@/store/features/version_distribution";
const useSetVersionDistData = (times: string) => {
  //直接使用useDispatch分发dispatch
  const dispatch = useDispatch();
  const queryVersionDistData = async () => {
    const res = await queryVersionDistribution({
      times,
    });
    dispatch(setVerisionDistData(res));
  };
  useEffect(() => {
    queryVersionDistData();
  }, [times]);
};

export default useSetVersionDistData;
